package com.geek.javase.ch16.work.work1;

/*
 *@author wangpeng
 *2025/11/2
 *@description TODO
 */
public class SleepTest {
    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new Thread(() -> {
            System.out.println("A");
            try {
                Thread.sleep(100); // 等待线程2打印B
                System.out.println("C");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });

        Thread thread2 = new Thread(() -> {
            try {
                Thread.sleep(50); // 确保线程1先打印A
                System.out.println("B");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });

        thread1.start();
        thread2.start();
    }
}